std::packaged_task
From Cppreference
| C++ Standard Library | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Thread support library | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::packaged_task | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:cpp/thread/packaged task/sidebar content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Defined in header <future>
| ||
| template< class > class packaged_task; //not defined
| (1) | (C++11 feature) |
| template< class Function, class Args... >
class packaged_task<Function(Args...)>; | (2) | (C++11 feature) |
The class template std::packaged_task packages a function to store its return value that is later acquired asynchronously via a std::future object, that the std::packaged_task can supply.
| This section is incomplete |
Contents |
[edit] Member functions
| constructs the task object (public member function) | |
| destructs the task object (public member function) | |
| moves the task object (public member function) | |
| checks if the task object has a valid function (public member function) | |
| swaps two task objects (public member function) | |
Getting the result | ||
| returns a future associated with the promised result (public member function) | |
Execution | ||
| executes the function (public member function) | |
| executes the function ensuring that the result is ready only once the current thread exits (public member function) | |
| resets the state abandoning any stored results of previous executions (public member function) | |
[edit] Non-member functions
| This section is incomplete |